#ifndef __TRACELOG__H__
#define __TRACELOG__H__

#include <stdio.h>

#include "RTCS.h"
#include "RTCStype.h"
#include "RTCSerror.h"
#include "RTCSbaseObject.h"
#include "RTCSCString.h"

#define RTCS_TRACELEVEL_TCP		1
#define RTCS_TRACELEVEL_UDP		1
#define RTCS_TRACELEVEL_SERVER	1
#define RTCS_TRACELEVEL_APP		1
#define RTCS_TRACELEVEL_CLIENT  1

//##ModelId=3AAC610B019A
class RTCS_TraceLog  
{
public:
	RTCS_TraceLog(RTCS_CTstring fname,RTCS_CTuint level=5,RTCS_CTint maxsize=1024*1024);
	//##ModelId=3AAC610B0228
	virtual ~RTCS_TraceLog();

	//##ModelId=3AAC610B0213
	void Trace(RTCS_CTuint level, const char *format ,...);
	//##ModelId=3AAC610B01FE
	void TraceNoTime(RTCS_CTuint level, const char *format ,...);
	//##ModelId=3AAC610B01F4
	void LogTime(RTCS_CTuint level);
	//##ModelId=3AAC610B01EB
	void TraceLevel(RTCS_CTuint level);

private:
	//##ModelId=3AAC610B01E0
	RTCS_CTbool Passed(RTCS_CTuint level);

	//##ModelId=3AAC610B01D8
	RTCS_CTuint		m_Level;
	//##ModelId=3AAC610B01CE
	RTCS_CTstring	m_Logname;
	//##ModelId=3AAC610B01C2
	FILE*			m_Handle;
	//##ModelId=3AAC610B01BA
	RTCS_CTint		m_MaxSize;

	//##ModelId=3AAC610B01AE
	RTCS_Lock		m_Lock;
	
};


/**************************\
** inline implementations **
\**************************/

inline void RTCS_TraceLog::TraceLevel(RTCS_CTuint level)
{ 
	m_Level = level; 
}

inline RTCS_CTbool RTCS_TraceLog::Passed(RTCS_CTuint level)
{
	return level<=m_Level ? RTCS_CTboolTRUE : RTCS_CTboolFALSE;
}

#endif 
